package com.originit.product.server.vo


data class ResultVO<T> (var code:Int? = null,
                        var msg:String? = null,
                        var data:T? = null)
{
    fun isSuccess():Boolean{
        return data == SUCCESS_VAL
    }

    companion object{

        // 成功的返回code
        const val SUCCESS_VAL = 0

        fun <T> success(data:T? = null, msg:String = "请求成功", code:Int = 0):ResultVO<T> {
            return ResultVO<T>(code, msg, data)
        }

        fun <T> fail(msg: String? = "服务器内部异常", code:Int = -1, data:T? = null): ResultVO<T> {
            return ResultVO<T>(code, msg, data)
        }
    }
}